import { defineStore } from 'pinia';
// 引入获取试卷详情信息 的接口
import { getTestPaperDetail } from '@/api/assessment/testpapermanage.js'
export const useTestpaperDetailStore = defineStore('testpaperdetail', () => {
  const testpaperdetail = ref([]);

  async function getTestPaperDetailData (id) {
    const res = await getTestPaperDetail(id)
    testpaperdetail.value = res.data.topics
  }



  const singleChoice = computed(() => testpaperdetail.value.filter(item => item.topicType == 0))
  const multipleChoice = computed(() => testpaperdetail.value.filter(item => item.topicType == 1))
  const judgeChoice = computed(() => testpaperdetail.value.filter(item => item.topicType == 2))
  const fillChoice = computed(() => testpaperdetail.value.filter(item => item.topicType == 3))
  const discussChoice = computed(() => testpaperdetail.value.filter(item => item.topicType == 4))

  // 清空试卷详情信息
  function clearTestPaperDetailData () {
    testpaperdetail.value = []
  }

  return { testpaperdetail, getTestPaperDetailData, clearTestPaperDetailData, singleChoice, multipleChoice, judgeChoice, fillChoice, discussChoice }
})